<html>
<head>
    <title>添加手续费</title>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="/static/layui//css/layui.css">
    <script src="/static/layui/layui.all.js"></script>
    <script src="/static/js/jquery.min.js"></script>
    <script src="/static/js/dealParam.js"></script>

</head>
<body>
<form class="layui-form" method="get" style="width:80%;" >

    <div class="layui-form-item">
        <label class="layui-form-label">交易货币</label>
        <div class="layui-input-block">
            <select id="coinTypeSelect" name="coinTypeId">
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">等级数字</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" id="level" name="level" placeholder="请输入等级数字">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">等级名称</label>
        <div class="layui-input-block">

            <input type="text" class="layui-input" id="name" name="name" placeholder="请输入等级名称">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">休眠币数量</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" id="sleepCoinCount" name="sleepCoinCount" placeholder="请输入配发休眠币数量">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">活币数量</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" id="aliveCoinCount" name="aliveCoinCount" placeholder="请输入配发活币数量">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="button" class="layui-btn" onclick="add()">立即提交</button>
            <#--<button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
        </div>
    </div>
</form>
<script>
    var coinTypeList = getCoinTypeList();
    var coinTypeOptionList = '';

    $.each(coinTypeList, function (index, coinType) {
        coinTypeOptionList += '<option value="' + coinType.id + '">' + coinType.name + '</option>';
    });
    var coinTypeSelect = $("#coinTypeSelect");
    coinTypeSelect.append($(coinTypeOptionList));

    layui.use('form', function () {
        var form = layui.form;
        form.render('select'); //刷新select选择框渲染
        //监听提交
        form.on('submit(*)', function (data) {
            window.location.href = 'back/admin/level/listpage';
        });
    });
    var level = $("#level").val();
    console.log(level);

    function add() {
        var coinTypeSelect = $("#coinTypeSelect").val();
        console.log(coinTypeSelect);
        var level = $("#level").val();
        var name = $("#name").val();
        var sleepCoinCount = $("#sleepCoinCount").val();
        var aliveCoinCount = $("#aliveCoinCount").val();


        $.ajax({
            url: "/back/admin/level/add",
            type: "GET",
            data: {
                coinTypeId: coinTypeSelect,
                level: level,
                name: name,
                sleepCoinCount: sleepCoinCount,
                aliveCoinCount: aliveCoinCount
            },
            success: function (baseDto) {
                window.location.href="/back/admin/level/listpage";
            }
        });
    }




</script>
</body>
</html>